package com.kymatrix.kycarbon.xsmd.kbpm.server.controller;

import com.kymatrix.kycarbon.xsmd.kbpm.server.base.CommonPage;
import com.kymatrix.kycarbon.xsmd.kbpm.server.base.CommonResult;
import com.kymatrix.kycarbon.xsmd.kbpm.server.model.form.Groups;
import com.kymatrix.kycarbon.xsmd.kbpm.server.model.form.IdParam;
import com.kymatrix.kycarbon.xsmd.kbpm.server.model.form.IdsParam;
import com.kymatrix.kycarbon.xsmd.kbpm.server.core.dto.ProcessDesignHisPageParam;
import com.kymatrix.kycarbon.xsmd.kbpm.server.core.dto.ProcessDesignHisParam;
import com.kymatrix.kycarbon.xsmd.kbpm.server.core.service.ProcessDesignHisService;
import com.kymatrix.kycarbon.xsmd.kbpm.server.core.vo.ProcessDesignHisEntityVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
    * 流程设计历史 前端控制器
    * </p>
*
* @author mldong
* @since 2023-09-25
*/
@RestController
@Api(tags = "流程设计历史管理")
@RequiredArgsConstructor
public class ProcessDesignHisController {
    private final ProcessDesignHisService processDesignHisService;
    /**
     * 添加流程设计历史
     * @param param
     * @return
     */
    @PostMapping("/wf/processDesignHis/save")
    @ApiOperation(value = "添加流程设计历史")
    public CommonResult<?> save(@RequestBody @Validated({Groups.Save.class}) ProcessDesignHisParam param) {
        processDesignHisService.save(param);
        return CommonResult.ok();
    }
    /**
     * 删除流程设计历史
     * @param param
     * @return
     */
    @PostMapping("/wf/processDesignHis/remove")
    @ApiOperation(value = "删除流程设计历史")
    public CommonResult<?> remove(@RequestBody IdsParam param) {
        processDesignHisService.removeBatchByIds(param.getIds());
        return CommonResult.ok();
    }
    /**
     * 修改流程设计历史
     * @param param
     * @return
     */
    @PostMapping("/wf/processDesignHis/update")
    @ApiOperation(value = "修改流程设计历史")
    public CommonResult<?> update(@RequestBody @Validated({Groups.Update.class}) ProcessDesignHisParam param) {
        processDesignHisService.update(param);
        return CommonResult.ok();
    }
    /**
     * 查询单个流程设计历史
     * @param param
     * @return
     */
    @PostMapping("/wf/processDesignHis/detail")
    @ApiOperation(value = "查询单个流程设计历史")
    public CommonResult<ProcessDesignHisEntityVO> detail(@RequestBody IdParam param) {
        ProcessDesignHisEntityVO processDesignHis = processDesignHisService.findById(param.getId());
        return CommonResult.data(processDesignHis);
    }
    /**
     *分页查询流程设计历史列表
     * @param param
     * @return
     */
    @PostMapping("/wf/processDesignHis/page")
    @ApiOperation(value = "分页查询流程设计历史列表")
    public CommonResult<CommonPage<ProcessDesignHisEntityVO>> page(@RequestBody ProcessDesignHisPageParam param) {
        return CommonResult.data(processDesignHisService.page(param));
    }
}
